package queries;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import entitys.LoginUser;
import enums.Position;
import enums.Result;
import enums.Status;

/**
 * updates the status of the current employee to 'OFFLINE'
 * @author Dima
 *
 */
public class LogoutQuery {

	@SuppressWarnings("resource")
	public static Result exe(LoginUser loginUser,Connection conn) {
		Statement stmt;

		try {
			stmt = conn.createStatement();
			stmt.executeUpdate("UPDATE ccrm.employee SET employee.status = 'OFFLINE' WHERE userid = '"+ loginUser.getUserId() +"';");
			return Result.OK;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return Result.ERROR;
		}
		
	}
}
